package com.wj.graph;

/**
 * 有向图
 * @author wen.jie
 * @date 2021/8/27 15:56
 */
public class Digraph extends Graph{

    public Digraph(int v) {
        super(v);
    }

    //向图中添加一条边 v->w
    @Override
    public void addEdge(int v, int w) {
        adj[v].enqueue(w);
        E++;
    }

    //该图的反向图
    private Digraph reverse() {
        Digraph digraph = new Digraph(V);
        for (int v = 0; v < V; v++) {
            for (Integer w : adj[v]) {
                digraph.addEdge(w, v);
            }
        }
        return digraph;
    }

}
